package ch.zbw.pra.sysventory.domain.businesslogic;

public class UserManagement {

	private String visitorUserName;
	private String visitorUserPassword;
	private String inventorUserName;
	private String inventorUserPassword;

	private String isLoggedInAs;
	private boolean hasInventorRights;

	public UserManagement() {
		super();

		this.visitorUserName = "visitor";
		this.visitorUserPassword = "visitor";
		this.inventorUserName = "inventor";
		this.inventorUserPassword = "inventor";

		this.hasInventorRights = false;

	}

	public boolean checkUser(String username, String userpassword) {
		boolean canLogin = false;
		if (!this.inventorUserName.isEmpty() && !this.inventorUserPassword.isEmpty() || !this.visitorUserName.isEmpty() && !this.visitorUserPassword.isEmpty()) {

			if (!username.isEmpty() && !userpassword.isEmpty()) {
				if (this.visitorUserName.equals(username) && this.visitorUserPassword.equals(userpassword)) {
					canLogin = true;
					setHasInventorRights(false);
				}
				if (this.inventorUserName.equals(username) && this.inventorUserPassword.equals(userpassword)) {
					canLogin = true;
					setHasInventorRights(true);
				}
			}
		}

		return canLogin;

	}

	public String getIsLoggedInAs() {
		return this.isLoggedInAs;
	}

	public void setIsLoggedInAs(String isLoggedInAs) {
		this.isLoggedInAs = isLoggedInAs;
	}

	public boolean isHasInventorRights() {
		return this.hasInventorRights;
	}

	public void setHasInventorRights(boolean hasInventorRights) {
		this.hasInventorRights = hasInventorRights;
	}

	public String getVisitorUserName() {
		return this.visitorUserName;
	}

	public String getVisitorUserPassword() {
		return this.visitorUserPassword;
	}

	public String getInventorUserName() {
		return this.inventorUserName;
	}

	public String getInventorUserPassword() {
		return this.inventorUserPassword;
	}

}
